import Vue from 'vue'
import VueRouter from 'vue-router'

//引入组件
import Login from '@/views/login/Login.vue';
import Layout from '@/views/layout/Layout.vue';

Vue.use(VueRouter)

const routes = [
    //登陆页
    {
        path: '/login',
        component: Login
    },
    //首页
    {
        path: '/home',
        component: Layout,
        redirect: '/home',
        children: [{
            path: '/home',
            component: () =>
                import ('@/views/home/Home.vue')
        }]
    },

    //订单管理
    {
        path: '/order',
        component: Layout,
        redirect: '/order',
        children: [{
            path: '/order',
            component: () =>
                import ('@/views/order/OrderList.vue')
        }]
    },
    //商品管理
    {
        path: '/goods',
        component: Layout,
        redirect: '/goods/goodslist',
        children: [
            //商品列表
            {
                path: '/goods/goodslist',
                component: () =>
                    import ('@/views/goods/GoodsList.vue')
            },
            //商品添加
            {
                path: '/goods/goodsadd',
                component: () =>
                    import ('@/views/goods/GoodsAdd.vue')
            },
            //商品分类
            {
                path: '/goods/cateadd',
                component: () =>
                    import ('@/views/goods/CateAdd.vue')
            }
        ]
    },
    //店铺管理
    {
        path: '/shop',
        component: Layout,
        redirect: '/shop',
        children: [{
            path: '/shop',
            component: () =>
                import ('@/views/shop/Shop.vue')
        }]
    },
    //账号管理
    {
        path: '/account',
        component: Layout,
        redirect: '/account/accountlist',
        children: [
            { path: '/account/accountlist', component: () =>
                    import ('@/views/account/AccountList.vue') },
            { path: '/account/accountadd', component: () =>
                    import ('@/views/account/AccountAdd.vue') },
            { path: '/account/modify', component: () =>
                    import ('@/views/account/Modify.vue') }
        ]
    },
    //销售统计
    {
        path: '/total',
        component: Layout,
        redirect: '/total/goodstotal',
        children: [{
                path: '/total/goodstotal',
                component: () =>
                    import ('@/views/total/GoodsTotal.vue')
            },
            {
                path: '/total/ordertotal',
                component: () =>
                    import ('@/views/total/OrderTotal.vue')
            }
        ]
    },
]

const router = new VueRouter({
    routes
})

export default router